package com.ruoyi.web.controller.system;

import java.io.IOException;
import java.net.URLEncoder;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.Material;
import com.ruoyi.system.service.IMaterialService;

/**
 * 物料管理
 */
@RestController
@RequestMapping("/system/material")
public class SysMaterialController extends BaseController {

    // @Autowired
    // private IMaterialService materialService;
    //
    // /**
    //  * 获取物料列表
    //  */
    // @PreAuthorize("@ss.hasPermi('system:material:list')")
    // @GetMapping("/list")
    // public TableDataInfo list(Material material) {
    //     startPage();
    //     List<Material> list = materialService.selectMaterialList(material);
    //     return getDataTable(list);
    // }
    //
    //
    // /**
    //  * 导出物料列表
    //  */
    // @Log(title = "物料管理", businessType = BusinessType.EXPORT)
    // @PreAuthorize("@ss.hasPermi('system:material:export')")
    // @PostMapping("/export")
    // public void export(HttpServletResponse response, Material material)
    // {
    //     List<Material> list = materialService.selectMaterialList(material);
    //     ExcelUtil<Material> util = new ExcelUtil<Material>(Material.class);
    //     util.exportExcel(response, list, "物料数据");
    // }
    //
    // /**
    //  * 导入物料数据
    //  */
    // @Log(title = "物料管理", businessType = BusinessType.IMPORT)
    // @PreAuthorize("@ss.hasPermi('system:material:import')")
    // @PostMapping("/importData")
    // public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
    //     ExcelUtil<Material> util = new ExcelUtil<>(Material.class);
    //     List<Material> materialList = util.importExcel(file.getInputStream());
    //     String operName = getUsername();
    //     String message = materialService.importMaterial(materialList, updateSupport, operName);
    //     return success(message);
    // }
    //
    // /**
    //  * 下载导入模板
    //  */
    // @PostMapping("/importTemplate")
    // public void importTemplate(HttpServletResponse response) {
    //     ExcelUtil<Material> util = new ExcelUtil<>(Material.class);
    //     util.importTemplateExcel(response, "物料数据");
    // }
    //
    // /**
    //  * 根据物料ID获取详细信息
    //  */
    // @PreAuthorize("@ss.hasPermi('system:material:query')")
    // @GetMapping(value = { "/", "/{materialId}" })
    // public AjaxResult getInfo(@PathVariable(value = "materialId", required = false) Long materialId) {
    //     AjaxResult ajax = AjaxResult.success();
    //     if (materialId != null) {
    //         Material material = materialService.selectMaterialById(materialId);
    //         ajax.put(AjaxResult.DATA_TAG, material);
    //     }
    //     return ajax;
    // }
    //
    // /**
    //  * 新增物料
    //  */
    // @PreAuthorize("@ss.hasPermi('system:material:add')")
    // @Log(title = "物料管理", businessType = BusinessType.INSERT)
    // @PostMapping
    // public AjaxResult add(@Validated @RequestBody Material material) {
    //     return toAjax(materialService.insertMaterial(material));
    // }
    //
    // /**
    //  * 修改物料
    //  */
    // @PreAuthorize("@ss.hasPermi('system:material:edit')")
    // @Log(title = "物料管理", businessType = BusinessType.UPDATE)
    // @PutMapping
    // public AjaxResult edit(@Validated @RequestBody Material material) {
    //     return toAjax(materialService.updateMaterial(material));
    // }
    //
    // /**
    //  * 删除物料
    //  */
    // @PreAuthorize("@ss.hasPermi('system:material:remove')")
    // @Log(title = "物料管理", businessType = BusinessType.DELETE)
    // @DeleteMapping("/{materialIds}")
    // public AjaxResult remove(@PathVariable Long[] materialIds) {
    //     return toAjax(materialService.deleteMaterialByIds(materialIds));
    // }
}